<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

  <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="Sales Quotation Search Results"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form prependId="false" rendered="#{loginBacking.searchSalesQuotation}">
                <p:panel header="Sales Quotation Search Results for: #{salesQuotationEntityController.input}">
                    <p:messages />
                    <br />
                <h:outputText escape="false" value="#{bundle.ListSalesQuotationEntityEmpty}" rendered="#{salesQuotationEntityController.searchItems.rowCount == 0}"/>
                <h:panelGroup rendered="#{salesQuotationEntityController.searchItems.rowCount > 0}">
                    <p:dataTable value="#{salesQuotationEntityController.searchItems}" 
                                     var="item" style="table-layout:fixed"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                        <p:column filterBy="#{item.id}">
                            <f:facet name="header">
                                <h:outputText value="Id"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>

                        <p:column filterBy="#{item.salesLead.fullname}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesQuotationEntityTitle_salesLead}"/>
                            </f:facet>
                            <h:outputText value="#{item.salesLead.firstName}&nbsp;#{item.salesLead.lastName}"/>
                        </p:column>
                        
                        <p:column filterBy="#{item.customer.fullname}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesQuotationEntityTitle_customer}"/>
                            </f:facet>
                            <h:outputText value="#{item.customer.firstName}&nsbp;#{item.customer.lastName}"/>
                        </p:column>
                        
                        <p:column filterBy="#{item.systemUser.fullname}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="SystemUser"/>
                            </f:facet>
                            <h:outputText value="#{item.systemUser.firstName}&nsbp;#{item.systemUser.lastName}"/>
                        </p:column>
                        
                        <p:column filterBy="#{item.createdBy.fullname}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesQuotationEntityTitle_createdBy}"/>
                            </f:facet>
                            <h:outputText value="#{item.createdBy.firstName}&nsbp;#{item.createdBy.lastName}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListSalesQuotationEntityTitle_createdAt}"/>
                            </f:facet>
                            <h:outputText value="#{item.createdAt}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>   
                        
                        <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" action="#{salesQuotationEntityController.prepareView}" ajax="false"/>
                            </p:column>
                        
                        <p:column>
                            <p:menuButton value="Options"> 
                            
                            <p:menuitem ajax="false" icon="ui-icon ui-icon-disk" action="#{salesQuotationEntityController.prepareEdit}" value="#{bundle.ListSalesQuotationEntityEditLink}"/>
                            
                            <p:menuitem ajax="false" icon="ui-icon ui-icon-disk" action="#{salesQuotationEntityController.prepareQuote}" value="Revise" rendered="#{salesQuotationEntityController.checkSystemUser()==true}"/>
                            
                            <p:menuitem ajax="false" icon="ui-icon ui-icon-disk" action="#{salesQuotationEntityController.prepareEditLeadTime}" value="Set Lead Time" rendered="#{salesQuotationEntityController.checkSystemUser()==true}"/>
                            
                            <p:menuitem ajax="false" icon="ui-icon ui-icon-close" action="#{salesQuotationEntityController.destroy}" value="Delete" rendered="#{item.archived==false and salesQuotationEntityController.checkSystemUser()==true}"/>
                            
                            </p:menuButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                </p:panel>
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareCreate}" value="New Request For Quotation"/>
                &nbsp;
                <p:commandButton ajax="false" action="#{salesQuotationEntityController.prepareList}" value="Show All Quotations"/>
                &nbsp;
                <p:commandButton ajax="false" value="Show All Unreviewed" action="#{salesQuotationEntityController.getUnquotedItems}" immediate="true" />
                &nbsp;
                <p:commandButton ajax="false" value="Search Again" action="/entities/salesQuotationEntity/Search" immediate="true" />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
